package com.ice.framework.utils

import android.annotation.SuppressLint
import android.widget.TextView
import androidx.lifecycle.LifecycleCoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class MobileCodeUtils() {

    @SuppressLint("SetTextI18n")
    fun countDown(lifecycleScope:LifecycleCoroutineScope, tv: TextView) {
        lifecycleScope.launch {
            tv.isClickable = false
            for (i in 60 downTo 1){
                delay(1000)
                if (i > 1) {
                    tv.text = "${i-1}s"
                } else {
                    tv.isClickable = true
                    tv.text = "获取验证码"
                    break
                }
            }
        }
    }
}